﻿using DHQGHN.DAL.Base;
using DHQGHN.DAL.Models.DHQG;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DHQGHN.DAL.DAO.DHQG
{
    public class History_CommentDAO : SqlDAO
    {
        public const string PROCEDURE_INSERT = "spHISTORY_COMMENT_Insert";
        public const string PROCEDURE_GET_ALL = "spHistory_Comment_GetGetAll";

        public const string PARAM_BAN_ID = "@BAN_ID";
        public const string PARAM_NAM_KE_HOACH_ID = "@NAM_KE_HOACH_ID";
        public const string PARAM_MOC = "@MOC";
        public const string PARAM_NHOM_DON_VI_ID = "@NHOM_DON_VI_ID";
        public const string PARAM_NHOM_CHI_TIEU = "@NHOM_NHOM_CHI_TIEU";
        public const string PARAM_FLAG = "@FLAG";
        public const string PARAM_CHI_TIEU_ID = "@CHI_TIEU_ID";
        public const string PARAM_DON_VI_ID = "@DON_VI_ID";
        public const string PARAM_GIA_TRI = "@GIA_TRI";
        public const string PARAM_COMMENT_DV = "@COMMENT_DV";
        public const string PARAM_COMMENT_BAN = "@COMMENT_BAN";
        public const string PARAM_IS_ACTIVE = "@IS_ACTIVE";
        public const string PARAM_STATUS_ID = "@STATUS_ID";
        public const string PARAM_MOC_KIEM_SOAT_ID = "@MOC_KIEM_SOAT_ID";


        //flag:0 Báo cáo thực hiện >> gữa đơn vị và Ban
        public History_CommentDAO(string connectionString, System.Type type) :
            base(connectionString, type) { }
        public int Insert(History_Comment hm)
        {
            try
            {
                SqlCommand cmd = this.GetSprocCommand(PROCEDURE_INSERT);
                cmd.Parameters.Add(new SqlParameter(PARAM_BAN_ID, hm.BAN_ID));
                cmd.Parameters.Add(new SqlParameter(PARAM_CHI_TIEU_ID, hm.CHI_TIEU_ID));
                cmd.Parameters.Add(new SqlParameter(PARAM_COMMENT_BAN, hm.COMMENT_BAN));
                cmd.Parameters.Add(new SqlParameter(PARAM_DON_VI_ID, hm.DON_VI_ID));
                cmd.Parameters.Add(new SqlParameter(PARAM_COMMENT_DV, hm.COMMENT_DV));
                cmd.Parameters.Add(new SqlParameter(PARAM_FLAG, hm.FLAG));
                cmd.Parameters.Add(new SqlParameter(PARAM_MOC, hm.MOC));
                cmd.Parameters.Add(new SqlParameter(PARAM_MOC_KIEM_SOAT_ID, hm.MOC_KIEM_SOAT_ID));
                cmd.Parameters.Add(new SqlParameter(PARAM_NAM_KE_HOACH_ID, hm.NAM_KE_HOACH_ID));

                int result = ExecuteNonQuery(cmd);
                return result;
            }
            catch
            {
                throw;
            }
        }
        public List<History_Comment> Getallhstory(int namkh, int moc, int mocks, int flag, int dv, int ct)
        {
            try
            {

                SqlCommand cmd = this.GetSprocCommand(PROCEDURE_GET_ALL);
                cmd.Parameters.Add(new SqlParameter(PARAM_NAM_KE_HOACH_ID, namkh));
                cmd.Parameters.Add(new SqlParameter(PARAM_MOC, moc));
                cmd.Parameters.Add(new SqlParameter(PARAM_MOC_KIEM_SOAT_ID, mocks));
                cmd.Parameters.Add(new SqlParameter(PARAM_FLAG, flag));
                cmd.Parameters.Add(new SqlParameter(PARAM_DON_VI_ID, dv));
                cmd.Parameters.Add(new SqlParameter(PARAM_CHI_TIEU_ID, ct));
                return GetList<History_Comment>(cmd);
            }
            catch
            {
                throw;
            }
        }


    }
}
